function [zero one two three four five six seven eight nine ...
    zero_t one_t two_t three_t four_t five_t six_t seven_t eight_t nine_t test training] = parsedata()
    % read training set
    training = dlmread('zip.train');

    % read test set
    test = dlmread('zip.test');

    % training digit matrices
    zero = zeros(1194,256);
    one = zeros(1005,256);
    two = zeros(731,256);
    three = zeros(658,256);
    four = zeros(652,256);
    five = zeros(556,256);
    six = zeros(664,256);
    seven = zeros(645,256);
    eight = zeros(542,256);
    nine = zeros(644,256);

    % test digit matrices
    zero_t = zeros(359,256);
    one_t = zeros(264,256);
    two_t = zeros(198,256);
    three_t = zeros(166,256);
    four_t = zeros(200,256);
    five_t = zeros(160,256);
    six_t = zeros(170,256);
    seven_t = zeros(147,256);
    eight_t = zeros(166,256);
    nine_t = zeros(177,256);

    % row count
    cZero = 1;
    cOne = 1;
    cTwo = 1;
    cThree = 1;
    cFour = 1;
    cFive = 1;
    cSix = 1;
    cSeven = 1;
    cEight = 1;
    cNine = 1;

    for i = 1:size(training,1)
        switch training(i,1)
            case 0
                zero(cZero,:) = training(i,2:end);
                cZero = cZero + 1;
            case 1
                one(cOne,:) = training(i,2:end);
                cOne = cOne + 1;
            case 2
                two(cTwo,:) = training(i,2:end);
                cTwo = cTwo + 1;
            case 3
                three(cThree,:) = training(i,2:end);
                cThree = cThree + 1;
            case 4
                four(cFour,:) = training(i,2:end);
                cFour = cFour + 1;
            case 5
                five(cFive,:) = training(i,2:end);
                cFive = cFive + 1;
            case 6
                six(cSix,:) = training(i,2:end);
                cSix = cSix + 1;
            case 7
                seven(cSeven,:) = training(i,2:end);
                cSeven = cSeven + 1;
            case 8
                eight(cEight,:) = training(i,2:end);
                cEight = cEight + 1;
            case 9
                nine(cNine,:) = training(i,2:end);
                cNine = cNine + 1;
        end
    end

    % row count
    cZero = 1;
    cOne = 1;
    cTwo = 1;
    cThree = 1;
    cFour = 1;
    cFive = 1;
    cSix = 1;
    cSeven = 1;
    cEight = 1;
    cNine = 1;

    for i = 1:size(test,1)
        switch test(i,1)
            case 0
                zero_t(cZero,:) = test(i,2:end);
                cZero = cZero + 1;
            case 1
                one_t(cOne,:) = test(i,2:end);
                cOne = cOne + 1;
            case 2
                two_t(cTwo,:) = test(i,2:end);
                cTwo = cTwo + 1;
            case 3
                three_t(cThree,:) = test(i,2:end);
                cThree = cThree + 1;
            case 4
                four_t(cFour,:) = test(i,2:end);
                cFour = cFour + 1;
            case 5
                five_t(cFive,:) = test(i,2:end);
                cFive = cFive + 1;
            case 6
                six_t(cSix,:) = test(i,2:end);
                cSix = cSix + 1;
            case 7
                seven_t(cSeven,:) = test(i,2:end);
                cSeven = cSeven + 1;
            case 8
                eight_t(cEight,:) = test(i,2:end);
                cEight = cEight + 1;
            case 9
                nine_t(cNine,:) = test(i,2:end);
                cNine = cNine + 1;
        end
    end
end